Skip to content

fix(common): MeshValue.eq returns true when the other value has extra units - #876

Merged
twwu123 merged 2 commits into
MeshJS:mainfrom
takinanton:fix/mesh-value-eq-extra-units
Nov 28, 2026
Merged

twwu123 merged 2 commits into
MeshJS:mainfrom
takinanton:fix/mesh-value-eq-extra-units

Conversation

@takinanton

Copy link
Copy Markdown
Contributor

Summary

MeshValue.eq only walks the units of the left side so a value that is a subset of the other one compares as equal. new MeshValue({ lovelace: 20n }).eq(new MeshValue({ lovelace: 20n, [unit]: 10n })) returns true and an empty value equals anything. TxTester.inputsValue and outputsValue use eq so they can pass when the expected value has assets the tx does not carry.

Added a unit count check before the per unit comparison. There were no tests for eq so I added a few next to the geq and leq ones. Two of them fail on main and pass now.

Affect components

  • @meshsdk/common
  • @meshsdk/contract
  • @meshsdk/core
  • @meshsdk/core-csl
  • @meshsdk/core-cst
  • @meshsdk/hydra
  • @meshsdk/provider
  • @meshsdk/react
  • @meshsdk/svelte
  • @meshsdk/transaction
  • @meshsdk/wallet
  • Mesh playground (i.e. https://meshjs.dev/)
  • Mesh CLI

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Bug fix (non-breaking change which fixes an issue)
  • Code refactoring (improving code quality without changing its behavior)
  • Documentation update (adding or updating documentation related to the project)

Related Issues

None that I could find.

Checklist

  • My code is appropriately commented and includes relevant documentation, if necessary
  • I have added tests to cover my changes, if necessary
  • I have updated the documentation, if necessary
  • All new and existing tests pass (i.e. npm run test)
  • The build is pass (i.e. npm run build)

Additional Information

I ran the @meshsdk/common jest suite after building common, core-csl, core-cst, transaction, wallet and core with build:mesh. 22 suites and 206 tests pass including the tx-tester one. I did not run the other packages' suites or the full turbo build.

🤖 Generated with Claude Code

…nits

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@twwu123
twwu123 merged commit dd976cc into MeshJS:main Nov 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants